#ifndef		__ENGINE_APPLICATION_H_INCLUDED__
#define		__ENGINE_APPLICATION_H_INCLUDED__

#include	"Commandline.h"

#define		RUN_APP(AppClass)	int main(int argc, char * argv[]) { return AppClass().Start(argc, argv); }

/**
 * Simple application model.
 */
class Application {
public:
	Application();
	virtual ~Application() {}

	/**
	 * Run this application.
	 *
	 * \param argc Number of command line arguments.
	 * \param argv Command argument list.
	 * \return Exit code.
	 */
	int Start(int argc, char * argv[]);

	/**
	 * Stop this application.
	 *
	 * \param code Exit code.
	 */
	void Stop(int code);

	/**
	 * Lock frame-per-second.
	 *
	 * \param fps Frame per second.
	 */
	void LockFPS(int fps);

	/**
	 * Initailize interface for detail application implementation.
	 *
	 * \param cmd Command line arguments.
	 * \return Should we stop this application?
	 */
	virtual bool OnInit(const Commandline & cmd) { return true; }

	/**
	 * Frame update interface.
	 */
	virtual void OnBreath() {}

	/**
	 * Jobs to do before real exit.
	 */
	virtual void OnExit() {}

protected:
	bool _is_running;
	int _exit_code;
	double _frame_time;
};

#endif//!	__ENGINE_APPLICATION_H_INCLUDED__
